package com.tianpengtech.admin.opertion;

import java.util.List;

import com.tianpengtech.common.model.opertion.Opertion;

public class OperationDao {

	
	public static OperationDao ME = new OperationDao();
	
	/**
	 * 根据对象ID和对象的操作类型查找对应的操作记录集合
	 * @param obj_id
	 * @param opt_type
	 * @return
	 */
	public List<Opertion> queryOperationsByObjId(int obj_id,int opt_type){
		String sql="select * from "+Opertion.dao.tableName()
		+" where "+Opertion.OBJ_ID+"=? and "+Opertion.OPT_TYPE+"=? order by id desc ";
		return Opertion.dao.find(sql,obj_id,opt_type);
	}

	
	/**
	 * 记录操作日志信息
	 * @param obj_id
	 * @param opt_type
	 * @param user
	 * @param content
	 */
	public void recordLog(long obj_id,int opt_type,long user,String content ){
		Opertion opertion = new Opertion();
		opertion.set(Opertion.OBJ_ID, obj_id);
		opertion.set(Opertion.OPT_TYPE, opt_type);
		opertion.set(Opertion.OPT_USER, user);
		opertion.set(Opertion.CONTENT, content);
		opertion.save();
	}
}
